import {getCatesByPid} from "../../service/goods";

Page({
    data: {
        nav: {
            title:'商品分类',
            background:"#fff"
        },
        loading:true,
        wrapHeight:"calc(100vh - 100rpx - 176rpx - 128rpx - 24rpx)",
        cates:null,
        options:{},
    },
    onLoad: function (options = {}) {

        (async () => {

            console.log("optionsCate", options)

            const cates = await getCatesByPid(0)
            this.setData({
                cates,
                options,
                loading: false,
            })

        })()
    },
    getList(e){
        const {items} = e.detail
        this.setData({
            courses:items
        })
    },
    cateChange(e){
        const {cate,type, key} = e.detail
        if (type=='search'){
            wx.navigateTo({
                url: `/pages/goods/list?key=${key||''}`,
            })
        }else{
            wx.navigateTo({
                url: `/pages/cate/search?cate_id=${cate.id}`,
            })
        }

    }

});
